package com.shengruan.admin.action;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.shengruan.admin.jdbc.AuctionHistoryJdbc;
import com.shengruan.admin.vo.AuctionHistory;
import com.shengruan.common.BaseAction;
import com.shengruan.framework.pager.Pager;


public class AuctionHistoryAction extends BaseAction {

    Logger logger = LoggerFactory.getLogger(getClass());

    private AuctionHistoryJdbc auctionHistoryJdbc = (AuctionHistoryJdbc) this.getJdbc(AuctionHistoryJdbc.class);

    @Override
    public void execute() throws Exception {

        String productId = this.input("productId");
        String status = this.input("status");
        int currentPage = 1;
        try {
            currentPage = Integer.parseInt(this.input("currentPage"));
        } catch (Exception ex) {
        }

        Pager pager = new Pager(currentPage, auctionHistoryJdbc.getRows(Integer.valueOf(productId)), 30);
        List<AuctionHistory> auctionHistoryList = auctionHistoryJdbc.findWithPage(currentPage, 30, Integer.valueOf(productId));

        this.setRequest("productId", productId);
        this.setRequest("pager", pager);
        this.setRequest("auctionHistoryList", auctionHistoryList);
        this.setRequest("status", status);
        this.forward("/admin/product/auction-history-list.jsp");

    }
}
